package javasec.contempt.dialogs;

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class PasswordDialog extends Dialog
{
	String stringValue=null;
	Text stringText=null;
	public boolean aborted=true;
	
	public PasswordDialog(Shell parent)
	{
		super(parent);
	}
	
	public String getString()
	{
		return stringValue;
	}
	
	protected void okPressed()
	{
		aborted=false;
		stringValue=stringText.getText();
		super.okPressed();
	}
	
	protected Control createDialogArea(Composite parent)
	{	
		Composite composite = new Composite(parent,0);
		composite.setLayout(new GridLayout(2,false));
		composite.setLayoutData(new GridData(GridData.FILL_BOTH));
	
		Label stringLabel=new Label(composite,SWT.None);
		stringLabel.setText("password: ");
		stringLabel.pack();
		
		stringText=new Text(composite,SWT.LEFT|SWT.PASSWORD|SWT.BORDER);
		stringText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		
		return composite;
	}
	
	protected void configureShell(Shell newShell)
	{
		super.configureShell(newShell);
		newShell.setText("enter password");
	}
}
